<template>
	<page-loading :show="resultData">
		<view class="wrap">
			<view class="mb140">
				<view class="headerBg">{{ statusList[resultData.status] }}</view>
				<view class="list mart40p">
					<view class="title">
						<view class="headImg"><image :src="resultData.headportrait" mode="widthFix"></image></view>
						<view class="shopName">
							{{ resultData.truename }}
							<i-icon icon="iconfanhui" type="single" class="mr-5 middle rotate180" size="28rpx" color="#666"></i-icon>
						</view>
					</view>
					<view class="listItem">
						<view class="left">
							<view class="carImg"><image :src="'https://files.yzsheng.com/goodimg/brandimg/' + resultData.brand_id + '.png'" mode="aspectFit"></image></view>
							车型 :
						</view>
						<view class="right">{{ resultData.car_type_name }}{{ resultData.configuration_name }}</view>
					</view>

					<view class="listItem">
						<view class="left">外观内饰：</view>
						<view class="right">天空蓝/红色</view>
					</view>
					<view class="listItem">
						<view class="left">指导价：</view>
						<view class="right">{{ resultData.factoryprice }}万</view>
					</view>
					<view class="listItem">
						<view class="left">上户地区：</view>
						<view class="right">{{ resultData.province }}{{ resultData.city }}</view>
					</view>
					<view class="bottom-flex">
						<view class="width-50 u-text-center u-border-right" @click="contactSeller">
							<i-icon icon="iconxiaoxi1" type="multiple" class="middle marr5" size="34rpx"></i-icon>
							联系买家
						</view>
						<view class="width-50 u-text-center" @click="call">
							<i-icon icon="icondianhua" type="multiple" class="middle marr5" size="34rpx"></i-icon>
							致电买家
						</view>
					</view>
				</view>
				<view class="list">
					<view class="title">过往询价信息</view>
					<view class="callListItem">
						<view class="left">
							<view class="font-28 color-333">落地总金额</view>
							<view class="font-24 color-999">落地价+必要花费+商业保险</view>
						</view>
						<view class="right line74 colEB5C02">￥{{ resultData.total_money }}</view>
					</view>
					<view class="callListItem border-bottom0">
						<view class="left"><view class="font-28 color-333">裸车价格</view></view>
						<view class="right color-666">{{ resultData.car_money }}</view>
					</view>
				</view>
				<view class="list" v-if="resultData.status === 1" v-for="(it, index) in resultData.list" :key="index">
					<view class="title">{{ it.addTime.split('T')[0] }} {{ it.addTime.split('T')[1] }}</view>
					<view class="callListItem">
						<view class="left"><view class="font-28 color-999">报价员</view></view>
						<view class="right color-666">{{ it.truename }}</view>
					</view>
					<view class="callListItem">
						<view class="left"><view class="font-28 color-999">裸车价格</view></view>
						<view class="right colEB5C02">￥{{ it.quoted_price }}万</view>
					</view>
					<view class="callListItem">
						<view class="left width-30"><view class="font-28 color-999">提车期限</view></view>
						<view class="right left width-70 color-666">{{ returnDate(it.get_car_deadline) }}</view>
					</view>
					<view class="callListItem border-bottom0">
						<view class="left"><view class="font-28 color-999">备注</view></view>
						<view class="right color-666">{{ it.remark }}</view>
					</view>
				</view>
				<view class="list">
					<view class="title"><view class="shopName">订单信息</view></view>
					<view class="listItem">
						<view class="width-30 color-999">订单号：</view>
						<view class="width-70 color-333" @click="copy(resultData.order_no)">
							{{ resultData.order_no }}
							<text class="copy ml-10">复制</text>
						</view>
					</view>
					<view class="listItem">
						<view class="width-30 color-999">订单发起时间：</view>
						<view class="width-70 color-333" v-if="resultData.addtime">{{ resultData.addtime.split('T')[0] }} {{ resultData.addtime.split('T')[1] }}</view>
					</view>
					<view class="listItem" v-for="(it, index) in resultData.list" :key="index">
						<view class="width-30 color-999">{{ it.truename }}报价时间：</view>
						<view class="width-70 color-333">{{ it.addTime.split('T')[0] }} {{ it.addTime.split('T')[1] }}</view>
					</view>
				</view>
				<view class="fixedBottomBtn" v-if="resultData.status === 1 || resultData.status === 0">
					<view class="btn-bg-yellow width-90" @click="addQuotation">
						<i-icon v-if="resultData.status === 1" icon="icontianjia_1" type="single" class="mr-5 middle rotate180" size="38rpx" color="#333"></i-icon>
						<text v-if="resultData.status === 1">新增报价</text>
						<text v-else-if="resultData.status === 0">报价</text>
					</view>
				</view>
				<view class="fixedBottomBtn" v-else>
					<view class="btnWrap flex-jc-c">
						<view class="left width-50" @click="contactSeller">
							<i-icon icon="iconxiaoxi" type="single" class="middle marr5" size="34rpx" color="#FFE03B"></i-icon>
							<text>联系客户</text>
						</view>
						<view class="right width-50" @click="call">
							<i-icon icon="iconlianxi" type="single" class="middle marr5" size="34rpx" color="#333"></i-icon>
							<text>致电客户</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</page-loading>
</template>
<script>
import { AddMobileContactData } from '@/utils/common-api.js';
export default {
	data() {
		return {
			resultData: {},
			statusList: ['待报价', '待确认', '完成', '关闭']
		};
	},
	props: ['status', 'id', 'pageFrom'],
	created() {
		this.GetLowPayOrderCarDetails();
	},
	methods: {
		// 获取详情
		async GetLowPayOrderCarDetails() {
			uni.showLoading({
				title: '加载中'
			});

			try {
				const res = await this.$api.carOrder.GetCarFindDetails({ id: this.id });
				uni.hideLoading();
				console.log(res);
				this.resultData = res.data;
			} catch (err) {
				uni.hideLoading();
				console.log(err);
			}
		},
		returnDate(date) {
			let text = '';
			if (date > 0 && date <= 7) {
				text = '7天';
			} else if (date > 7 && date <= 15) {
				text = '15天';
			} else {
				text = '30天';
			}
			return text;
		},
		// 复制
		copy(data) {
			uni.setClipboardData({
				data: data,
				success: function() {
					console.log('success');
				}
			});
		},
		addQuotation() {
			uni.navigateTo({
				url: '/pages_order/newQuotation/newQuotation?id=' + this.resultData.id + '&name=' + this.resultData.truename
			});
		},
		// 联系买家
		contactSeller() {
			if (this.pageFrom === 'chat') {
				uni.navigateBack();
				return;
			}
			AddMobileContactData(this.$store.state.userInfoDetail.store.storeId);
			this.$store.commit('news/createConversationActive', {
				user: this.resultData.truename, //店铺名称
				img: this.resultData.headportrait, //店铺头像
				lastTime: '', //
				userId: this.resultData.accountid, //店铺id
				conversationID: 'C2C' + this.resultData.accountid
			});
			this.$store.commit('news/setCardInfo', {
				imgSrc: 'https://files.yzsheng.com/goodimg/brandimg/' + this.resultData.brand_id + '.png',
				name: this.resultData.car_type_name + ' ' + this.resultData.configuration_name,
				// price: '',
				// labelPrige: '',
				type: 'resaleCar',
				goPage: '2' //客户端页面跳转参数
			});
			uni.navigateTo({
				url: '/pages_news/contactSeller/contactSeller?user=' + this.resultData.truename + '&pageId=' + this.resultData.id + '&tab=2'
			});
		}
	}
};
</script>

<style scoped lang="scss">
@import '../retailOrder.scss';
</style>
